home *** CD-ROM | disk | FTP | other *** search
/ Crosscountry USA Photo Safari / Crosscountry USA Photo Safari.iso / Data / cc_base / pak00_16bit_f.pk3 / common / calc_accident.c4 next >
Text File  |  2002-11-29  |  5KB  |  150 lines

  1.       
  2. {
  3.   @calc_accident {
  4.     resid Player;
  5.     resid Game;
  6.     
  7.     str accident_message;
  8.     
  9.     int player_fatigue;
  10.     int player_hunger;
  11.     int fatigue_threshold;
  12.     int hunger_threshold;
  13.     int score;
  14.     int threshold;
  15.     int rain;
  16.     int snow;
  17.     int no_wipers;
  18.     int no_chains;
  19.     int night;
  20.     int no_headlights;    
  21.     int fatigued;
  22.     int starving;
  23.     int speeding;
  24.     int time_last_accident;
  25.     int time_now;
  26.     int time_between_accidents;
  27.     
  28.     Game   = ResByName("Game");
  29.     Player = ResPropGetResID(Game,"game_cur_player");
  30.  
  31.     ResPropAlias( Player, "nav_accident_message", "accident_message");
  32.     ResPropAlias( Player,"time_last_accident","time_last_accident");
  33.     
  34.     player_fatigue     = ResPropGetInt(Player,"player_fatigue");   
  35.     player_hunger      = ResPropGetInt(Player,"player_hunger");
  36.     fatigue_threshold  = ResPropGetInt(Game,"game_fatigue_threshold");   
  37.     hunger_threshold   = ResPropGetInt(Game,"game_hunger_threshold");
  38.     time_between_accidents = ResPropGetInt(Game,  "game_time_between_accidents");
  39.     time_now               = ResPropGetInt(Player,"time_now");
  40.  
  41.     /* SCORES */
  42.     threshold      = ResPropGetInt(Game,"game_accident_threshold");
  43.     rain           = 5;
  44.     snow           = 10;
  45.     no_wipers      = 10;
  46.     no_chains      = 5; 
  47.     night          = 5; 
  48.     no_headlights  = 10;    
  49.     fatigued       = 20;
  50.     starving       = 20;
  51.     speeding       = 10;
  52.     
  53.     if ( (time_last_accident + time_between_accidents) > time_now ) {
  54.       stop;
  55.     }
  56.  
  57.  
  58.     accident_message = MangleSIDToStr(262/*"You had an accident because: "*/);
  59.  
  60.      
  61.     /* check if its raining */
  62.     if (StrExact(ResPropGetStr(Player,"weather_precip"),"r")) {
  63.       score += rain;
  64.       
  65.       accident_message = StrCat(accident_message, MangleSIDToStr(263/*" it was raining,"*/));
  66.       /* check for wipers */
  67.       if (ResPropGetInt(Player,"truck_wiper")==0) {
  68.         accident_message = StrCat(accident_message, MangleSIDToStr(264/*" your wipers were off,"*/));
  69.         score += no_wipers;
  70.       }      
  71.     }
  72.     
  73.     /* check if its snowing*/
  74.     if (StrExact(ResPropGetStr(Player,"weather_precip"),"s")) {
  75.       score += snow;
  76.       accident_message = StrCat(accident_message, MangleSIDToStr(265/*" it was snowing,"*/));
  77.       /* check for wipers */
  78.       if (ResPropGetInt(Player,"truck_wiper")==0) {
  79.         score += no_wipers;
  80.         accident_message = StrCat(accident_message, MangleSIDToStr(266/*" your wipers were off,"*/));     
  81.       }
  82.       /* check for chains */
  83.       if (ResPropGetInt(Player,"truck_chains_on")==0) {
  84.         accident_message = StrCat(accident_message, MangleSIDToStr(267/*" you did not have your chains on,"*/));
  85.         score += no_chains;
  86.       }
  87.     }
  88.  
  89.     /* check for chains on pavement*/
  90.     if (StrExact(ResPropGetStr(Player,"weather_precip"),"d")) {
  91.       /* check for chains */
  92.       if (ResPropGetInt(Player,"truck_chains_on")==0) {
  93.         accident_message = StrCat(accident_message, MangleSIDToStr(268/*" you had your chains on,"*/));      
  94.         score += no_chains;
  95.       }
  96.     }
  97.  
  98.     /* check for speeding */
  99.     if (ResPropGetInt(Player,"truck_speeding")==1) {
  100.       accident_message = StrCat(accident_message, MangleSIDToStr(269/*" you were speeding,"*/));      
  101.       score += speeding;
  102.     }
  103.  
  104.     /* check if its night time */
  105.     if (StrExact(ResPropGetStr(Player,"weather_time_of_day"),"n")) {
  106.       score += night;
  107.       accident_message = StrCat(accident_message, MangleSIDToStr(270/*" it was night,"*/)); 
  108.  
  109.       /* check for headlights */
  110.       if( ResPropGetInt(Player,"truck_light") == 0 ) {
  111.         accident_message = StrCat(accident_message, MangleSIDToStr(271/*" your lights were off,"*/));       
  112.         score += no_headlights;
  113.       }
  114.     }
  115.  
  116.     /* check for starving */
  117.     if (player_hunger >= hunger_threshold) {
  118.       accident_message = StrCat(accident_message, MangleSIDToStr(272/*" you were too hungry to concentrate,"*/)); 
  119.       score += starving;
  120.     }
  121.  
  122.     /* check for falling asleep */
  123.     if (player_fatigue >= fatigue_threshold) {
  124.       accident_message = StrCat(accident_message, MangleSIDToStr(273/*" you were falling asleep,"*/));    
  125.       score += fatigued;
  126.     }
  127.  
  128.     /* break off comma  */
  129.     accident_message = StrLeft(accident_message,(StrLen(accident_message)-1));
  130.     
  131.     /* add period */
  132.     accident_message = StrCat(accident_message,".");
  133.  
  134.     if (score >= threshold) {
  135.       CVarSetInt("guiInputEnabled",0);
  136.       ResPropSetInt( Player, "truck_broken", 1);
  137.       ResPropSetInt(ResByName("dash.gl/SegmentController"),"state",10);
  138.       ResParseEvent(ResByName("dash.gl/brake_pedal"),"@activate");
  139.       ResParseEvent(ResByName("dash.gl/ignition_switch"),"@activate");
  140.       time_last_accident = time_now;
  141.     }
  142.  
  143.  
  144.  
  145.     LogStr(LOG_DEBUG,"\n\n\n\nACCIDENT SCORE: %d\n\n\n\n\n\n",score);
  146.     
  147.   }    
  148. }      
  149.       
  150.